package m.store.model;

import m.common.model.*;
import m.common.model.type.FieldType;
import m.common.model.util.ModelQueryList;
import m.common.model.util.QueryCondition;

import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

@TableMeta(name = "ts_sale_info", description = "出库信息")
public class SaleInfo extends OrderModel implements MigrationModel {
    @Override
    public List<String> migrationOidList(String storeOid) throws Exception {
        return ModelQueryList.getModelList(this.getClass(),new String[]{"oid"},null,
                        QueryCondition.eq("store.oid",storeOid))
                .stream().map(Model::getOid).collect(Collectors.toList());
    }
    @FieldMeta(name="sale_amount",type= FieldType.DOUBLE,description="出库金额")
    private Double saleAmount;
    @FieldMeta(name="sale_date",type= FieldType.DATE,description="出库日期")
    private Date saleDate;
    @FieldMeta(name = "remark",type = FieldType.STRING,length = 1000,description = "备注")
    private String remark;
    @FieldMeta(name="in_income_amount",type= FieldType.DOUBLE,defaultValue = "0",description="收款中金额")
    private Double inIncomeAmount;
    @FieldMeta(name="has_virtual_stock",type= FieldType.STRING,defaultValue = "N",description="是否有虚拟库存",dictOption = "Y:有,N:没有")
    private String hasVirtualStock;
    public final static String Has_Yes="Y";
    public final static String Has_No="N";

    @FieldMeta(name="type",type= FieldType.STRING,defaultValue = "A",description="类型",dictOption = "A:正常出库,C:生产出库,D:盘点出库,R:入库退货")
    private String type;
    public final static String Type_Sale="A";
    public final static String Type_Produce="C";
    public final static String Type_Count="D";
    public final static String Type_Refund="R";
    @LinkTableMeta(name="refund_stock_oid",table= StockInfo.class,description="退入库")
    private StockInfo refundStock;
    @FieldMeta(name="refund_amount",type= FieldType.DOUBLE,defaultValue = "0",description="退款金额")
    private Double refundAmount;

    //冗余信息
    @FieldMeta(name="income_status",type= FieldType.STRING,defaultValue = "N",description="收款状态",dictOption = "N:未到款,A:部分到款,Y:已到款,W:无需到款")
    private String incomeStatus;
    @FieldMeta(name="income_amount",type= FieldType.DOUBLE,defaultValue = "0",description="收款金额|收款记录金额汇总")
    private Double incomeAmount;
    @FieldMeta(name="owe_amount",type= FieldType.DOUBLE,defaultValue = "0",description="尚欠金额|客户欠：出库金额-退款金额-收款金额，退入库无需到款尚欠0")
    private Double oweAmount;

    public String getHasVirtualStock() {
        return hasVirtualStock;
    }

    public void setHasVirtualStock(String hasVirtualStock) {
        this.hasVirtualStock = hasVirtualStock;
    }

    public Double getSaleAmount() {
        return saleAmount;
    }

    public void setSaleAmount(Double saleAmount) {
        this.saleAmount = saleAmount;
    }

    public Date getSaleDate() {
        return saleDate;
    }

    public void setSaleDate(Date saleDate) {
        this.saleDate = saleDate;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Double getInIncomeAmount() {
        return inIncomeAmount;
    }

    public void setInIncomeAmount(Double inIncomeAmount) {
        this.inIncomeAmount = inIncomeAmount;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public StockInfo getRefundStock() {
        return refundStock;
    }

    public void setRefundStock(StockInfo refundStock) {
        this.refundStock = refundStock;
    }

    public Double getRefundAmount() {
        return refundAmount;
    }

    public void setRefundAmount(Double refundAmount) {
        this.refundAmount = refundAmount;
    }

    public String getIncomeStatus() {
        return incomeStatus;
    }

    public void setIncomeStatus(String incomeStatus) {
        this.incomeStatus = incomeStatus;
    }

    public Double getIncomeAmount() {
        return incomeAmount;
    }

    public void setIncomeAmount(Double incomeAmount) {
        this.incomeAmount = incomeAmount;
    }

    public Double getOweAmount() {
        return oweAmount;
    }

    public void setOweAmount(Double oweAmount) {
        this.oweAmount = oweAmount;
    }
}
